const http = require('http');
const urlLib = require('url');
const querystring = require('querystring');

let server = http.createServer((request,response) => {
	// 通过 request.headers['origin'] 来判断域名
	
	
	let {pathname:url, query:get} = urlLib.parse(request.url, true);
	let arr = [];
	request.on('data', data => {
		arr.push(data);
	})
	request.on('end', data => {
		let post = querystring.parse(Buffer.concat(arr).toString());

		console.log(url, get, post);
		response.write('123456')
		response.end();
		response.setHeader('Access-Control-Allow-Origin', '*');
	})
})
server.listen(8080);